#include <asm.h>
#include <regdef.h>
#include <inst_test.h>

LEAF(n64_lwr_test)
    .set noreorder
    addiu s0, s0, 1
    li  s2, 0x0
###test inst
    TEST_LWR(0x1c2fac22, 0x523c6da6, 0x800d0000, 0x0000d8e0, 0x0000d8e0, 0x523c6da6)
    TEST_LWR(0xed6d7900, 0xce7208cc, 0x800d0000, 0x0000fb66, 0x0000fb64, 0xed6dce72)
    TEST_LWR(0xca18f110, 0x5c049582, 0x800d0000, 0x0000bd99, 0x0000bd98, 0xca5c0495)
    TEST_LWR(0x5aad1fd0, 0xac4b1780, 0x800d0000, 0x00007c00, 0x00007c00, 0xac4b1780)
    TEST_LWR(0xe004e1bc, 0xda7b346c, 0x800d0000, 0x0000c090, 0x0000c090, 0xda7b346c)
    TEST_LWR(0x6e0b0cd0, 0xd73e2db4, 0x800d0000, 0x00005b40, 0x00005b40, 0xd73e2db4)
    TEST_LWR(0x439a205a, 0xbe4a77e8, 0x800d0000, 0x0000a2cc, 0x0000a2cc, 0xbe4a77e8)
    TEST_LWR(0x0a33c840, 0xf4ab4800, 0x800d0000, 0x0000b4b0, 0x0000b4b0, 0xf4ab4800)
    TEST_LWR(0xe2a519a8, 0x2877c94c, 0x800d0000, 0x0000ea2f, 0x0000ea2c, 0xe2a51928)
    TEST_LWR(0x655c4dec, 0x0098fac0, 0x800d0000, 0x00009979, 0x00009978, 0x650098fa)
    TEST_LWR(0x5b355c10, 0xdd272af0, 0x800d0000, 0x00002c08, 0x00002c08, 0xdd272af0)
    TEST_LWR(0x6d8225a0, 0x6344a306, 0x800d0000, 0x0000ffdb, 0x0000ffd8, 0x6d822563)
    TEST_LWR(0x8db2beb8, 0x4abc4b20, 0x800d0000, 0x00002966, 0x00002964, 0x8db24abc)
    TEST_LWR(0xa1394d66, 0x616bde6c, 0x800d0000, 0x0000a774, 0x0000a774, 0x616bde6c)
    TEST_LWR(0x2e7cab9d, 0xff06c992, 0x800d0000, 0x00008bcc, 0x00008bcc, 0xff06c992)
    TEST_LWR(0x5a3d1800, 0xd7a8c8a4, 0x800d0000, 0x00005908, 0x00005908, 0xd7a8c8a4)
    TEST_LWR(0x95cd08a0, 0x03a05c60, 0x800d0000, 0x0000209a, 0x00002098, 0x95cd03a0)
    TEST_LWR(0x0d0faea6, 0x518796b9, 0x800d0000, 0x0000d467, 0x0000d464, 0x0d0fae51)
    TEST_LWR(0x86f1f37a, 0xf0379164, 0x800d0000, 0x0000c1e2, 0x0000c1e0, 0x86f1f037)
    TEST_LWR(0x0e5acaa0, 0x7dfb338f, 0x800d0000, 0x00003d44, 0x00003d44, 0x7dfb338f)
    TEST_LWR(0x35371180, 0x7d5b39d7, 0x800d0000, 0x00000818, 0x00000818, 0x7d5b39d7)
    TEST_LWR(0xe6d63b48, 0xdfd77136, 0x800d0000, 0x00007060, 0x00007060, 0xdfd77136)
    TEST_LWR(0x681afa00, 0x39380e87, 0x800d0000, 0x0000f179, 0x0000f178, 0x6839380e)
    TEST_LWR(0xb1e81ce0, 0x50c208a0, 0x800d0000, 0x00000e55, 0x00000e54, 0xb150c208)
    TEST_LWR(0x3785c8d2, 0x72881d29, 0x800d0000, 0x000041d8, 0x000041d8, 0x72881d29)
    TEST_LWR(0x309d5f18, 0x5548972d, 0x800d0000, 0x000093bb, 0x000093b8, 0x309d5f55)
    TEST_LWR(0x2b601458, 0x4b39a5b2, 0x800d0000, 0x0000e1f9, 0x0000e1f8, 0x2b4b39a5)
    TEST_LWR(0x0868ae18, 0x9bbc9370, 0x800d0000, 0x0000508c, 0x0000508c, 0x9bbc9370)
    TEST_LWR(0x07956ce8, 0x42dee6e0, 0x800d0000, 0x000024c0, 0x000024c0, 0x42dee6e0)
    TEST_LWR(0xf1e2e144, 0xbf440540, 0x800d0000, 0x00000b1f, 0x00000b1c, 0xf1e2e1bf)
    TEST_LWR(0x45033898, 0x97b0b7e0, 0x800d0000, 0x00008a20, 0x00008a20, 0x97b0b7e0)
    TEST_LWR(0x640eb090, 0x62a599dd, 0x800d0000, 0x00008a04, 0x00008a04, 0x62a599dd)
    TEST_LWR(0x196a8060, 0x5dd63c08, 0x800d0000, 0x00007c98, 0x00007c98, 0x5dd63c08)
    TEST_LWR(0x37361000, 0x095e5970, 0x800d0000, 0x0000133a, 0x00001338, 0x3736095e)
    TEST_LWR(0xda316e48, 0xbea34750, 0x800d0000, 0x0000a33f, 0x0000a33c, 0xda316ebe)
    TEST_LWR(0xec203173, 0xc031ad40, 0x800d0000, 0x00009b1e, 0x00009b1c, 0xec20c031)
    TEST_LWR(0x8183a320, 0xafb82437, 0x800d0000, 0x000028a1, 0x000028a0, 0x81afb824)
    TEST_LWR(0xb831b5fe, 0xca24e678, 0x800d0000, 0x00004de4, 0x00004de4, 0xca24e678)
    TEST_LWR(0x09755ba0, 0x9dfa8a00, 0x800d0000, 0x00006f82, 0x00006f80, 0x09759dfa)
    TEST_LWR(0x693763f5, 0xa3f0f1a0, 0x800d0000, 0x00006142, 0x00006140, 0x6937a3f0)
    TEST_LWR(0x94282fc0, 0x0d9c3b90, 0x800d0000, 0x0000c30c, 0x0000c30c, 0x0d9c3b90)
    TEST_LWR(0x5344bcc4, 0x4b019d84, 0x800d0000, 0x00001862, 0x00001860, 0x53444b01)
    TEST_LWR(0xaad2d5f8, 0xef9ab0c0, 0x800d0000, 0x0000e308, 0x0000e308, 0xef9ab0c0)
    TEST_LWR(0xdaccddb8, 0x5b3878b8, 0x800d0000, 0x0000e5f9, 0x0000e5f8, 0xda5b3878)
    TEST_LWR(0xfd84b238, 0xe24b2507, 0x800d0000, 0x0000058a, 0x00000588, 0xfd84e24b)
    TEST_LWR(0x696b8bba, 0xdc916b5c, 0x800d0000, 0x0000da80, 0x0000da80, 0xdc916b5c)
    TEST_LWR(0x915850ce, 0x8b480098, 0x800d0000, 0x0000d574, 0x0000d574, 0x8b480098)
    TEST_LWR(0x740a2bc0, 0xdad4ec00, 0x800d0000, 0x0000a777, 0x0000a774, 0x740a2bda)
    TEST_LWR(0xe5ec7328, 0xc749ab00, 0x800d0000, 0x0000c6ec, 0x0000c6ec, 0xc749ab00)
    TEST_LWR(0x84d0f680, 0x0feccbc4, 0x800d0000, 0x000029a4, 0x000029a4, 0x0feccbc4)
    
###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    sll t1, s0, 24
    or t0, t1, s3 
    sw t0, 0(s1)
    jr ra
    nop
END(n64_lwr_test)
